﻿#ifndef CLIENT_H
#define CLIENT_H

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif  // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include <memory>
#include <set>
#include <unordered_map>
#include <vector>

namespace kratos {
namespace service {
class ServiceBox;
}
}  // namespace kratos

namespace rpc {
class Transport;
}

class GuildServiceQueryProxy;
class GuildServiceBasicProxy;
class GuildServiceWelfareProxy;
class GuildServiceAuthProxy;
class GuildServiceBuildingProxy;

/**
 * @brief
 *
 */
class Client {
 public:
  Client(kratos::service::ServiceBox &service_box);

  void Register(const std::string &account, const std::string &passwd);
  
  void Unregister();

  /**
   * @brief Create a Guild object
   *
   */
  void CreateGuild(bool use_coro = true);

  /**
   * @brief Get the Guild Brief Data object
   *
   * @param request_type
   * @param guild_id
   * @param role_uuid
   */
  void GetGuildBrief(bool use_coro = true);

  /**
   * @brief 退出公会
   *
   */
  void QuitGuild(bool use_coro = true);

  /**
   * @brief Get the Guild Member object
   *
   * @param member_role_uuid
   */
  void GetGuildMember(const uint64_t member_role_uuid, bool use_coro = true);

  /**
   * @brief Get the All Guild Id object
   *
   * @param count
   */
  void GetGuildBriefList(const std::size_t count,
                         bool use_coro = true);
  /**
   * @brief 搜索公会
   * 
   * @param nam 
   * @param use_coro 
   */
  void SearchGuild(const std::string &name,
                   bool use_coro = true);
  /**
   * @brief 
   * 
   * @param use_coro 
   */
  void GetGuildApplication(bool use_coro = true);
  
  /**
   * @brief 
   *
   * @param guild_id 
   * @param role_uuid 
   * @param use_coro 
   */
  void ApplyJoinGuild(const uint64_t guild_id, const uint64_t invite_role_uuid, bool use_coro = true);

  /**
   * @brief 踢出公会成员
   *
   */
  void KickOutGuildMember(const uint64_t kick_role_uuid,
                          bool use_coro = true);

  /**
   * @brief 设置自动同意入会
   *
   */
  void SetAutoApproval(bool is_auto_approval, bool use_coro = true);

  /**
   * @brief 修改公会图标
   *
   */
  void ChangeGuildIconId(const uint32_t icon_id, bool use_coro = true);

  /**
   * @brief 修改公会名字
   *
   */
  void ChangeGuildName(const std::string &name, bool use_coro = true);

  /**
   * @brief 修改公会宣言
   *
   */
  void ChangeGuildDeclaration(const std::string &declaration,
                              bool use_coro = true);

  /**
   * @brief 修改公会通知
   *
   */
  void ChangeGuildAnnounce(const std::string &announce, bool use_coro = true);

  /**
   * @brief 发公会红包
   * @param use_coro 是否使用协程
   */
  void SendGuildRedEnvelope(bool use_coro = true);


  void LoginBasic(bool use_coro = true) {}
  
  void LogoutBasic() {}

  void LoginWelfare(bool use_coro = true);
  
  void LogoutWelfare();

  /**
   * @brief 建筑升级
   * @param use_coro 是否使用协程
   */
  void BuildingUpgrade(bool use_coro = true);

 public:

  std::set<uint64_t> m_guild_ids;

 private:
  std::shared_ptr<GuildServiceQueryProxy> prx_query_;
  std::shared_ptr<GuildServiceBasicProxy> prx_basic_;
  std::shared_ptr<GuildServiceWelfareProxy> prx_welfare_;
  std::shared_ptr<GuildServiceAuthProxy> prx_auth_;
  std::shared_ptr<GuildServiceBuildingProxy> prx_building_;

  uint64_t token_{0};
  uint64_t role_uuid_{0};
  uint64_t guild_id_{0};
};

#endif  // CLIENT_H